SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO



CREATE PROCEDURE dbo.[DnnProduct_GetPortalSetting]
	@PortalID int,
	@SettingName	nvarchar(50),
	@CultureCode	nvarchar(50)
AS
	SELECT 
		CASE WHEN LEFT(LOWER(dbo.DnnProduct_PortalSettings.SettingValue), 6) = 'fileid' 
			THEN
				(SELECT Folder + FileName  
					FROM dbo.DnnProduct_Files 
					WHERE 'fileid=' + convert(varchar,dbo.DnnProduct_Files.FileID) = dbo.DnnProduct_PortalSettings.SettingValue
				) 
			ELSE 
				dbo.DnnProduct_PortalSettings.SettingValue  
			END 
		AS SettingValue
	FROM dbo.DnnProduct_PortalSettings 
	WHERE  PortalID = @PortalID
		AND SettingName = @SettingName
GO
